const path = require('path');
const alias = require('./alias.config.js');
const globalLessVal = require('./src/styles/globalLessVal');
function resolve(dir) {
  return path.join(__dirname, dir);
}
console.log(resolve);
//const cdnJs = ['https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js','http://wechatfe.github.io/vconsole/lib/vconsole.min.js?v=3.3.0'];
//const cdnJs = ['https://unpkg.com/mqtt/dist/mqtt.min.js'];
const cdnJs = [];
//const cpuInfo = require('os').cpus();
const proxy = {
  // http://v1.zcloudtechs.cn http://10.7.7.6:10080/ http://10.7.7.10:10080/
  '(/)': {
    target: 'http://49.233.85.23:8080',
    ws: true,
    changeOrigin: true
  }
  // '(/)': {
  //   target: 'http://192.168.10.54:8080',
  //   ws: true,
  //   changeOrigin: true
  // }
};
module.exports = {
  publicPath: process.env.BASE_URL,
  outputDir: 'moduleTest',
  productionSourceMap: false,
  devServer: {
    // disableHostCheck: true,
    open: true,
    port: 9090,
    hotOnly: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy
  },
  css: {
    loaderOptions: {
      less: {
        globalVars: globalLessVal
      }
    }
  },
  chainWebpack: (config) => {
    // 别名
    for (let aliasKey in alias) {
      config.resolve.alias.set(aliasKey, alias[aliasKey]);
    }
    config.plugin('html').tap((args) => {
      args[0].cdnJs = cdnJs;
      return args;
    });
    return config;
  }
};
